package priv.sort.shell;

// 希尔排序
public class ShellSort {
    public static void sort(int[] arr) {
        int len = arr.length;
        // 增量
        for(int gap = len / 2; gap > 0; gap /= 2){
            for (int i = gap; i < len; i++) {
                int temp = arr[i];
                int j;
                for (j = i - gap; j >= 0 && arr[j] > temp; j -= gap) {
                    arr[j + gap] = arr[j];
                }
                arr[j + gap] = temp;
            }
        }
    }
}
